'''
Created on Jun 3, 2009

@author: user
'''
import unittest

from cliques import utils

class test_utils(unittest.TestCase):


    def testPowerset(self):
        expected_result = [[],[1],[2],[3],[1,2],[2,3],[1,3],[1,2,3]]
        values = [1,2,3]
        observed_result = list(utils.powerset(values))
        assert len(expected_result)==len(observed_result)
        for item in expected_result:
            assert item in observed_result 

        expected_result = [[]]
        values = []
        observed_result = list(utils.powerset(values))
        assert len(expected_result)==len(observed_result)
        assert observed_result[0]==[]

    def testStdev(self):
        values = [1,1,1,2,2,2,3,3,3]
        expected = float(6)/9
        assert utils.stdev(values)==expected
        
        values = [3,3,3,3,3,3]
        expected  = 0
        assert utils.stdev(values)==expected

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testPowerset']
    unittest.main()